Arrays 

int val = 12;

int[] arr = new int[12];

- Application#1: 
ArrayDemo2.java

- Application#2: 
Frequencies.java

Input: Line of text
Output: 
hi there
a: 0	A: 0 ---> idx = 0 ---> 'a' or 'A' ---> (char) (0 + 'a') ---> 'a' 
b: 0	B: 0 ---> idx = 1 ---> 'b' or 'B' ---> (char) (1 + 'a')
...
e: 2	E: 0
...
other: 1

lower ---> size = 26
lower[0]: used to count the 'a's
lower[1]: used to count the 'b's
...
lower[25]: used to count the 'z's

'a' ---> lower[0]
'b' ---> lower[1]
Challenge: to be able to enforce the following mappings:
'a' ---> 0
'b' ---> 1
...
'z' ---> 25

current - 'a'


upper ---> size = 26
When it comes to this array we will use the following expression to do the mappings: 
current - 'A'

=> 'A' --> 0; 'B' ---> 1 , etc...

other

53 counters ---> 3 counters only

- Command Line Arguments (args)
Application#3: ArgsDemo.java

- Objective: create a method that can process a variable number of parameters

Let us design a sum method that can handle any number of parameters

sum(1, 2) ---> 3
sum(2, 3, 4) ---> 9
etc...

Solution#1: Create multiple versions of the same method (Method overloading)

int sum(int num1, int num2) {
	return num1 + num2;
}

int sum(int num1, int num2, int num3) {
	return num1 + num2 + num3;
}	

Solution#2: Create a method that accepts as a parameter an array of values

int sum(int[] arr) {
	int result = 0;

	for(int val : arr) {
		result += val;
	}	

	return result;
}

int[] arr = {1, 2, 3};
System.out.println(sum(arr));

Solution#3: Variable length parameter list
int sum(int... list) {
	int result = 0;

	for(int val : list) {
		result += val;
	}	

	return result;

}

System.out.println(sum(1, 2, 3));
System.out.println(sum(1, 2));
System.out.println(sum()); 

int sum( double val1, char val2, int... list): Variable parameter list should always
come at the end. 

- Two-dimensional arrays:

mat
0	1	2
10	11	12
20	21	22



int[][] mat = new int[3][3];

mat.length ---> # of rows
mat[0].length ---> # or columns
mat[1].length
mat[2].length

System.out.println(mat[1][1]); // 11
System.out.println(mat[mat.length - 1][mat[0].length - 1]);

Application#4: TwoArrayDemo.java





















































